package cm.android.mytodoit.controller.listeners;

import android.app.ListActivity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Toast;
import cm.android.mytodoit.model.BuyElement;
import cm.android.mytodoit.view.DetailBuyView;

public class BuyListViewLongClickListener implements OnItemLongClickListener{
	
	private ListActivity listActivity;
	
	public BuyListViewLongClickListener(ListActivity listActivity){
		
		this.listActivity =  listActivity;
	}


	public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {

		BuyElement element = null;
		try {
			element = (BuyElement) listActivity.getListView().getAdapter().getItem(arg2);
			Intent intent = new Intent(listActivity, DetailBuyView.class);
			intent.putExtra(BuyElement.TC_ID, element.getId());
			listActivity.startActivity(intent);
			
		} catch (Exception e) {
			Toast.makeText(listActivity, "failed", Toast.LENGTH_SHORT).show();
		}
		
	
		return false;
	}

}
